package com.example.shopping.authority.mapper;


import com.example.shopping.authority.entity.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoleMapper {
    //查询全部角色
    @Select("select * from role")
    List<Role> getRoleList();

    //根据id查询角色
    @Select("select * from role where roleid=#{roleid}")
    List<Role> getRoleFind(@Param("roleid")int roleid);

    //添加一个角色
    @Insert("insert into role(rolename,roledesc) values(#{rolename},#{roledesc})")
    int getRoleAddList(@Param("rolename")String rolename,@Param("roledesc")String roledesc);

    //修改一个角色
    @Update("UPDATE  role SET rolename=#{rolename},roledesc=#{roledesc} WHERE roleid=#{roleid}")
    int getRoleUpdateList(@Param("rolename")String rolename,@Param("roledesc")String roledesc,@Param("roleid")int roleid);

    //删除一个角色
    @Delete("delete from role where roleid=#{roleid}")
    int getRoleDelList(@Param("roleid") int roleid);

    //分配角色权限
    @Update("UPDATE  role SET psids=#{psids} WHERE roleid=#{roleid}")
    int getRoleUpJueSeList(@Param("psids")String psids,@Param("roleid")int roleid);
}
